﻿using System;

namespace EventThresholdReached
{
    class Program
    {
        static void Main(string[] args)
        {
            Counter count = new Counter(new Random().Next(10));
            count.ThresholdReached += c_TsReached;////事件订阅者
            Console.WriteLine("输入't'的次数：");
            while (Console.ReadKey(true).KeyChar == 't')
            {
                Console.WriteLine("+1");
                count.Add(1);
            }
            //Console.WriteLine("Hello World!");




        }
        static void c_TsReached(object sender, ThresholdReachedEventArgs e)//事件订阅
        {
            Console.WriteLine("The threshold of {0} was reached at {1}.", e.Threshold, e.Time);
            Environment.Exit(0);
        }
    }
}
